<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateCustomerAddressTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customer_address', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('customer_id')->comment('客户ID');
            $table->unsignedBigInteger('express_id')->comment('快递ID');
            $table->string('areas', 100)->comment("省市区");
            $table->string('address', 100)->comment("地址");
            $table->string('contacts', 50)->comment("联系人");
            $table->string('phone', 20)->comment("联系方式");
            $table->string('remark', 1000)->nullable()->comment("备注");
            $table->timestamps();

            $table->unique(['customer_id', 'express_id']);
        });
        DB::statement(/** @lang text */ "ALTER TABLE `customer_address` comment '客户默认发货地址'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customer_address');
    }
}
